import BaseController  from '../../core/baseController';


export default class MarketGoodsController extends BaseController {
    constructor(ctx){
      super(ctx)
      this.service=ctx.service.goods.marketGoods,
      this.modelPrefix='goods.marketGoods'
    }

    async addMarketGoods() {
      const { body } = this.ctx.validateReq('goods.marketGoods.goods');
      const { goods = [], marketId } = body;
      const list = goods.map(goods_id => ({
          goods_id,
          market_id: marketId
      }));
      // 先删除原有数据
      await this.service.model.destroy({ where: { market_id: marketId } });

      const result =await this.service.bulkCreate(list);
      if (result) {
        this.ctx.success({
        });
      }
    }
}